import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { DictEnum } from '@vben/constants';
import { getPopupContainer } from '@vben/utils';

import { getDictOptions } from '#/utils/dict';
import dayjs from 'dayjs';


// 顶部搜索栏
export const querySchema: FormSchemaGetter = () => [

  {
    component: 'Input',
    fieldName: 'eventName',
    label: '事件名称',
  },
  // {
  //   component: 'Input',
  //   fieldName: 'status',
  //   label: '事件状态',
  // },
  {
    component: 'Select',
    componentProps: {
      getPopupContainer,
      options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
    },
    fieldName: 'status',
    label: '事件状态',
  },
];

// 表格列 key 和 label
export const columns: VxeGridProps['columns'] = [
  // { type: 'checkbox', width: 60 },
  // {
  //   title: '事件id',
  //   field: 'id',
  // },
  {
    title: '事件名称',
    field: 'eventName',
  },
  // {
  //   title: '事件状态',
  //   field: 'status',
  // },
  {
    field: 'status',
    title: '状态',
    slots: { default: 'status' },
    minWidth: 100,
  },
  {
    title: '创建者',
    field: 'createBy',
  },
  {
    title: '修改者',
    field: 'updateBy',
  },
  {
    title: '创建时间',
    field: 'createTime',
  },
  {
    title: '修改时间',
    field: 'updateTime',
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    resizable: false,
    width: 'auto',
  },
];

// 新增  或 修改，form内容
const defaultExpireTime = dayjs()
  .add(365, 'days')
  .startOf('day')
  .format('YYYY-MM-DD HH:mm:ss');
export const modalSchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
    fieldName: 'id',
    label: '主键',
  },
  {
    component: 'Input',
    fieldName: 'eventName',
    label: '事件名称',
    rules: 'required',
  },
  {
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
      optionType: 'button',
    },
    defaultValue: '0',
    fieldName: 'status',
    formItemClass: 'col-span-2 lg:col-span-1',
    label: '状态',
  },
];
